#-*-encoding:utf-8-*-

import matplotlib.pyplot as plt
def load_data():
    x = []
    y = []
    with open("../../data/feat/number.txt", "rb") as f:
        for line in f:
            number = map(float, line.strip().split(','))
            x.append(number[0])
            y.append(number[1])
    return x, y


def draw_number(x, y):
    plt.plot(x, y)
    plt.xlabel("rank")
    plt.ylabel("number of negative sample")

    plt.title("relation between rank and number of negative sample")

    plt.show()


def draw_rate(x, y):
    for i in range(len(x)):
        y[i] = y[i] / x[i]
    plt.plot(x, y)
    plt.xlabel("rank")
    plt.ylabel("negative sample rate")

    plt.title("realtion between rank and negative sample rate")
    plt.show()

if __name__ == '__main__':
    x, y = load_data()
    # draw_number(x, y)
    draw_rate(x, y)